<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<style type="text/css">
		.advance_tip_pwd{
			background-color: #fff;
		    left: 42%;
		    position: fixed;
		    top: 200px;
		    width: 487px;
		    z-index: 5;
		}
		
		
		</style>
	</head>
	
	<body>
		<div class="cinema_tip">
		    <div class="cinema_subject clearfix">
		        <div class="cinema_title">
		            <a href="#">审批管理</a>
		            >
		            <a href="#" class="cinema_option">用工审批</a>
		        </div>
		    </div>
			<form  id="sysEmployApplySearchForm" method="get">
		       <div class="cinema_search clearfix">
					<div class="cinema_button">
				        	<input id="sysUserInfoSearch" type="button" value="查询" name="" style="float: none;" class="cinema_inquiry movie_no" onclick = "searchEmployApply()">
					</div>
					<div class="cinema_condition width_84" >
						<div class="cinema_smart"  style="float:none">
							<div class="cinema_inter">	
								<label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 签证编号： </label>
								<input type="text" id="visaCode" name="visaCode" maxlength="50" placeholder="签证编号" class="col-xs-10 col-sm-2" value="${visaCode}"/>
							</div>
							
							<div class="cinema_inter">	
								<label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 申请时间： </label>
							    <input style="display:inline" type="text" id="startTime" name="startTime"  value = "${startDate}" maxlength="50" placeholder="请选择开始时间" class="col-xs-10 col-sm-2" class="Wdate" onFocus="WdatePicker({lang:'zh-cn',readOnly:true})"/>
								-
								<input style="display:inline" type="text" id="endTime" name="endTime" value = "${endDate}"  maxlength="50" placeholder="请选择结束时间" class="col-xs-10 col-sm-2" onFocus="WdatePicker({lang:'zh-cn',readOnly:true})"/>
							</div>
							
							<dt>
							<c:if test="${sessionScope.loginUser.roleId eq 1 || sessionScope.loginUser.roleId eq 7 ||sessionScope.loginUser.roleId eq 9}">
							<div class="cinema_inter" style="width:300px">
								<label class="col-sm-1 control-label no-padding-right" for="form-field-1" style="float:left;line-height:33px;padding-left:10px"> 项目名称： </label>
								<div style="float:left;margin-top: -15px">
								<select name="projectId" id="projectId">
									<option value="0">请选择项目名称</option>
										<c:forEach var="project" items="${projectRes.data}">
											<option value="${project.proId}" <c:if test="${project.proId eq projectId}">selected</c:if>>${project.name}</option>
										</c:forEach>
								</select>
								</div>
							</div>
							</c:if>
							</dt>
							
							<c:if test="${sessionScope.loginUser.roleId eq 1 || sessionScope.loginUser.roleId eq 7 || sessionScope.loginUser.roleId eq 8 ||sessionScope.loginUser.roleId eq 9}">
							<dt>
							<div class="cinema_inter" >
								<label class="col-sm-1 control-label no-padding-right" for="form-field-1" style="float:left;line-height:33px;padding-left:10px"> 状态： </label>
								<div style="float:left;margin-top: -15px">
								<select name="pstate" id="pstate">
									<option value="">请选择审批状态</option>
									<option value="0" <c:if test="${pstate eq '0'}">selected</c:if>>已发起</option>
									<option value="4" <c:if test="${pstate eq '4'}">selected</c:if>>工段已审批</option>
									<option value="5" <c:if test="${pstate eq '5'}">selected</c:if>>合同部已审批</option>	
									<option value="6" <c:if test="${pstate eq '6'}">selected</c:if>>项目经理已审批</option>	
									<option value="-3,-4,-5,-6" <c:if test="${pstate eq '-3,-4,-5,-6'}">selected</c:if>>已作废</option>
								</select>
								</div>
							</div>
							</dt>
							</c:if>
						</div>
					</div>
				</div>
			</form>
		</div>
		
		
		<div class="cinema_list">
		    <div class="movie_button">
		    <div>
			    <div class="column_content1"  style="overflow: auto;">
			        <table id="sysUserInfoDatas" width="100%" height="" border="0" cellpadding="0" cellspacing="1" class="border_top">
			            <tr style="background-color: rgb(243, 247, 255);">
			            	<th nowrap="" style="padding:0px 5px;width:200px">签证编号</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">里程桩号</th>
			                <th nowrap="" style="padding:0px 5px;width:200px">项目名称</th>
			                <!-- <th nowrap="" style="padding:0px 5px;width:100px">签证编号</th> -->
			                <th nowrap="" style="padding:0px 5px;width:100px">工程类别</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">工程量</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">施工工时</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">工时单价</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">费用</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">是否合同外</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">申请人</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">申请时间</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">审批状态</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">当前审批人</th>
			                <th nowrap="" style="padding:0px 5px;width:100px">操作</th>
			            </tr>
			            <c:forEach var="res" items="${res.data.rows}">
				            <tr class="odd" style="background-color: #fff;" id="userinfo_row_${res.applyId}" >
				            	<td style="padding:0px 5px;width:100px" title="${res.visaCode}">${res.visaCode}</td>
				                 <td style="padding:0px 5px;width:200px" title="${res.mileageCode}">${res.mileageCode}</td>
				                 <td  style="padding:0px 5px;width:200px" title="${res.project.name}">${res.project.name}</td>
				                 <!--<td  style="padding:0px 5px;width:200px" title="${res.visaCode}">${res.visaCode}</td> -->
				                 <td  style="padding:0px 5px;width:80px" title="${res.projectId}">
				                 <c:choose>
					                 <c:when test="${res.projectId==1}">路基</c:when>
					                 <c:when test="${res.projectId==2}">路面</c:when>
					                 <c:when test="${res.projectId==3}">桥涵</c:when>
					                 <c:when test="${res.projectId==4}">隧道</c:when>
					                 <c:otherwise>其他</c:otherwise>
					             </c:choose>
				                 </td>
				                 <td  style="padding:0px 5px;" title="${res.quantities}">${res.quantities}</td>
				                 <td  style="padding:0px 5px;" title="${res.onstructionHour}">${res.onstructionHour}</td>
				                 <td  style="padding:0px 5px;" title="${res.hourPrice}">${res.hourPrice}</td>
				                 <td  style="padding:0px 5px;" title="${res.fee}">${res.fee}</td>
				                 <td  style="padding:0px 5px;" title="${res.isPlan}">
				                 <c:choose>
					                 		<c:when test="${res.isPlan==1}">是</c:when>
					                 		<c:otherwise>否</c:otherwise>
					             </c:choose>
				                 </td>
				                 <td  style="padding:0px 5px;" title="${res.applyUserId}">${res.applyUser.userName}</td>
				                 <td  style="padding:0px 5px;" title="${res.applyTime}"><fmt:formatDate value="${res.applyTime}" pattern="yyyy-MM-dd HH:mm"/></td>
				                 <td  style="padding:0px 5px;" title="${res.state}">
					                <c:choose>
					                <c:when test="${res.state==0}">已发起</c:when>
					                <c:when test="${res.state==4}">工段已审批</c:when>
					                <c:when test="${res.state==5}">合同部已审批</c:when>
					                <c:when test="${res.state==6}">项目经理已审批</c:when>
					                <c:when test="${res.state==-3||res.state==-4||res.state==-5||res.state==-6}">已作废</c:when>
					                <c:when test="${res.state==6}">已通过</c:when>
					                </c:choose>
				                 		
				                 </td>
				                 
				                 <td  style="padding:0px 5px;" title="${res.state}">${res.nextUser.userName}</td>
				                 
				                 </td>
				                 <td style="padding:0px 5px;" >
									<c:if test="${roleId==4}">
					                 	<c:choose>
					                 		<c:when test="${res.state==0}">
					                 			<a style="margin-left: 3%;" href="${ctx}/sys/examine/beforeExam?id=${res.applyId}" title="审批">审批</a>
					                 		</c:when>
					                 		<c:otherwise>
					                 			<a style="margin-left: 3%;" href="${ctx}/sys/examine/viewExam?id=${res.applyId}" title="查看">查看</a>
					                 		</c:otherwise>
					                 	</c:choose>
					                 </c:if>
					                 <c:if test="${roleId==5}">
					                 	<c:choose>
					                 		<c:when test="${res.state==4}">
					                 			<a style="margin-left: 3%;" href="${ctx}/sys/examine/beforeExam?id=${res.applyId}" title="审批">审批</a>
					                 		</c:when>
					                 		<c:otherwise>
					                 			<a style="margin-left: 3%;" href="${ctx}/sys/examine/viewExam?id=${res.applyId}" title="查看">查看</a>
					                 		</c:otherwise>
					                 	</c:choose>
					                 </c:if>
					                 <c:if test="${roleId==6}">
					                 	<c:choose>
					                 		<c:when test="${res.state==5}">
					                 			<a style="margin-left: 3%;" href="${ctx}/sys/examine/beforeExam?id=${res.applyId}" title="审批">审批</a>
					                 		</c:when>
					                 		<c:otherwise>
					                 			<a style="margin-left: 3%;" href="${ctx}/sys/examine/viewExam?id=${res.applyId}" title="查看">查看</a>
					                 		</c:otherwise>
					                 	</c:choose>
					                 </c:if>
					                 <c:if test="${roleId==1||roleId==2||roleId==7||user.roleId==8||roleId==9}">
					                 		<a style="margin-left: 3%;" href="${ctx}/sys/examine/viewExam?id=${res.applyId}" title="查看">查看</a>
					                 		<c:if test="${res.state<0||roleId==1||user.roleId==8||roleId==9}">
					                 			<a style="margin-left: 3%;" href="javascript:deleteOrder(${res.applyId})" title="查看">删除</a>
					                 		</c:if>
					                 </c:if>
					                 
					                 
					                 <c:if test="${res.state==6}">
					                 		<a style="margin-left: 3%;" href="${ctx}/sys/examine/print?id=${res.applyId}" target="_blank" title="打印">打印</a>
					                 </c:if>                 
								</td>
				             </tr>
			            </c:forEach>
					</table>
				</div>
			</div><!-- /.row -->
			<div id="manager_page" class="manager_page clearfix">
				<!-- 分页跳转 -->
				<div class="manager_show">
					<p><span>跳转至</span><input id="pagenum" type="text" name="" value="${res.data.page}"/></p>
					<span id="toPage" class="manager_true"></span>
				</div>
				<!-- 分页数字导航栏 -->
				<div id="manager_number" class="manager_number"></div>
				<input type="hidden"  id=records  value="${res.data.records}"/>			<!-- 总记录数 -->
				<input type="hidden"  id="pageSize"  value="${res.data.pageSize}"/>  <!-- 每页个数 -->
				<input type="hidden"  id="pageCurrent"  value="${res.data.page}"/>  <!-- 当前页page -->
				<input type="hidden"  id="totalPage"  value="${res.data.total}"/>	    <!-- 总页数 -->
			</div>
		</div>
		<script type="text/javascript" src="${ctx}/static/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript">
		function searchEmployApply(){
			var startDate = $("#startTime").val();
			var endDate = $("#endTime").val();	
			$('#sysEmployApplySearchForm').submit();
		}
		
		function deleteOrder(rowId){
			$.ajax({
				type: "POST",
				dataType: "json",
				async: false,
				url: '${ctx}/sys/examine/updateById/'+rowId,
				success: function (data) {
							if(data!=undefined&&data.status!=undefined&&data.status.trim()=="0"){
								$("#userinfo_row_"+rowId).remove();
								alert("删除成功。");
							}else{
								alert("error:"+data.error);
							}
						 },
				error: function(data) {
							alert("删除失败。");
						}
			});
			return false;
		}
		</script>
	</body>
	
</html>
